package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.utils.StringUtils;

import com.ruoyi.system.domain.Approval;
import com.ruoyi.system.domain.ApprovalHistory;
import com.ruoyi.system.domain.TodoRequest;
import com.ruoyi.system.domain.vo.zbg.User;
import com.ruoyi.system.domain.zbg.*;
import com.ruoyi.system.mapper.AuditorMapper;
import com.ruoyi.system.mapper.TSysUserMapper;
import com.ruoyi.system.mapper.WarningAndExceptionDataMapper;
import com.ruoyi.system.mapper.WorkOrderMapper;
import com.ruoyi.system.service.ToDoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
public class ToDoServiceImpl implements ToDoService {
    @Autowired
    private WarningAndExceptionDataMapper warningAndExceptionDataMapper;
    @Autowired
    private WorkOrderMapper workOrderMapper;
    @Autowired
    private AuditorMapper auditorMapper;
    @Autowired
    private TSysUserMapper tSysUserMapper;

    @Override
    public List<ToDoVo> selectList(User user, TodoRequest todoRequest) {
        log.info("获取待办事项列表");
        ArrayList<ToDoVo> toDoVos = new ArrayList<>();
        //获取自己的待办事项列表
        if (StringUtils.isNotEmpty(user.getPhone())) {
            //判断自己是是否是县级以上管理身份
            QueryWrapper<Auditor> auditorQueryWrapper = new QueryWrapper<>();
            auditorQueryWrapper.eq("phone", user.getPhone());
            Auditor auditor = auditorMapper.selectOne(auditorQueryWrapper);
            if (ObjectUtils.isNotEmpty(auditor)) {
                //判断身份
                Integer isDistrictAuditor = auditor.getIsDistrictAuditor();
                if (ObjectUtils.isNotEmpty(isDistrictAuditor) && isDistrictAuditor == 1) {
                    //是区县审核人，
                    getdistricList(auditor, toDoVos, todoRequest);
//
                } else if (ObjectUtils.isNotEmpty(auditor.getIsDistrictAdmin()) && auditor.getIsDistrictAdmin() == 1) {
                    //是区县管理员，获取到自己审核的区县
                    getdistricListadmin(auditor, toDoVos, todoRequest);

                    return toDoVos;
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityTowerManager()) && auditor.getIsCityTowerManager() == 1) {
                    //是市级铁塔审核员，获取到全市关于铁塔的工单
                    return gettowList(toDoVos, todoRequest);

                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityElectricityManager()) && auditor.getIsCityElectricityManager() == 1) {
                    //是市级电力审核员，获取到全市关于电费的工单
                    return getelectricityList(toDoVos, todoRequest);
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityHomeCustomerManager()) && auditor.getIsCityHomeCustomerManager() == 1) {
                    //是市级家客审核员，获取到全市关于家客的工单
                    return gethomecustomerList(toDoVos, todoRequest);
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityEnterpriseCustomerManager()) && auditor.getIsCityEnterpriseCustomerManager() == 1) {
                    //是市级集客审核员，获取到全市关于集客的工单
                    return getenterprisecustomerList(toDoVos, todoRequest);
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityWirelessManager()) && auditor.getIsCityWirelessManager() == 1) {
                    //是市级无线审核员，获取到全市关于无线的工单
                    return getwirelessList(toDoVos, todoRequest);
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityLineManager()) && auditor.getIsCityLineManager() == 1) {
                    //是市级线路审核员，获取到全市关于线路的工单
                    return getlineList(toDoVos, todoRequest);
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityPowerManager()) && auditor.getIsCityPowerManager() == 1) {
                    //是市级动力审核员，获取到全市关于动力的工单
                    return getpowerList(toDoVos, todoRequest);
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityMaintenanceManager()) && auditor.getIsCityMaintenanceManager() == 1) {
                    //是市级代维审核员，获取到全市关于代维的工单
                    return getmaintenanceList(toDoVos, todoRequest);
                } else if (ObjectUtils.isNotEmpty(auditor.getIsCityAdmin()) && auditor.getIsCityAdmin() == 1) {
                    //是市级管理员，获取到全市的待办事项
                    return getcityList(toDoVos, todoRequest);

                }


            } else {

                //是区县维护员，获取到自己维护的工单
                if (todoRequest.getType() == 1) {
                    //查看自己是否是区县维护员
                    QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
                    workOrderQueryWrapper.eq("maintainer_phone", user.getPhone());
                    //分页 @TODO

                    List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
                    //获取全部需要自己处理的数据，包含已处理
                    if (CollectionUtils.isNotEmpty(workOrders)) {
                        workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            toDoVo.setRole(1);
                            if (workOrder.getMaintainerStatus() == 0){
                                toDoVo.setType(1);
                            }else {
                                toDoVo.setType(2);
                            }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);

                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        });
                    }
                } else if (todoRequest.getType() == 2) {
                    //获取需要自己处理的数据，未处理
                    //查看自己是否是区县维护员
                    QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
                    workOrderQueryWrapper.eq("maintainer_phone", user.getPhone());
                    workOrderQueryWrapper.eq("maintainer_status", 0);
                    //分页 @TODO
                    List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
                    //fenye
                    if (CollectionUtils.isNotEmpty(workOrders)) {
                        workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            toDoVo.setRole(1);
                           toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);

                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        });

                    }
                } else if (todoRequest.getType() == 3) {
                    //获取已办列表
                    //查看自己是否是区县维护员
                    QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
                    workOrderQueryWrapper.eq("maintainer_phone", user.getPhone());
                    workOrderQueryWrapper.eq("maintainer_status", 1);
                    //查询添加市级审核或区县审核不通过的工单
//                    workOrderQueryWrapper.ne("county_review_status", 2);
//                    workOrderQueryWrapper.ne("city_review_status", 2);
                    //分页 @TODO
                    List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);

                    if (CollectionUtils.isNotEmpty(workOrders)) {
                        workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            toDoVo.setRole(1);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        });


                    }


                }
            }
        }

        return toDoVos;
    }

    @Override
    public void approval(User user, Approval approval) {

        //设置设置工单序号
        WorkOrder workOrder1 = workOrderMapper.selectById(approval.getOrderNumber());
        if (approval.getRole()==1) {
            //设置维护时间
            workOrder1.setMaintainerTime(LocalDateTime.now());

            //设置通过状态
            if (ObjectUtils.isNotEmpty(approval.getApprovalStatus())){
              workOrder1.setMaintainerStatus(1);
            }
            //设置异常原因
            if (StringUtils.isNotEmpty(approval.getExceptionReason())){
                workOrder1.setMaintainerAbnormalReason(approval.getExceptionReason());
            }else {
                throw new RuntimeException("请填写异常原因");

            }
            //设置整改情况
            if (StringUtils.isNotEmpty(approval.getRectification())){
                workOrder1.setMaintainerRectification(approval.getRectification());

            }else {
                throw new RuntimeException("请填写整改情况");
            }
        }else if (approval.getRole()==2){
            //设置县级审核时间
            workOrder1.setCountyReviewTime(LocalDateTime.now());

            //设置通过状态
            if (ObjectUtils.isNotEmpty(approval.getApprovalStatus())){
                if (approval.getApprovalStatus()==0){
                    //不通过
                    workOrder1.setCountyReviewStatus(1);
                    workOrder1.setCountyReviewerPhone(user.getPhone());
                    //设置不通过原因
                    if (StringUtils.isNotEmpty(approval.getExceptionReason())){
                        workOrder1.setCountyReviewComment(approval.getRejectionReason());
                    }else {
                        throw new RuntimeException("请填写不通过原因");
                    }
                }else if (approval.getApprovalStatus()==1){
                    workOrder1.setCountyReviewerPhone(user.getPhone());
                    workOrder1.setCountyReviewStatus(2);
                }
            }

        }else if (approval.getRole()==4){
            if (ObjectUtils.isNotEmpty(approval.getApprovalStatus())){
                //设置市级审核时间
                workOrder1.setCityReviewTime(LocalDateTime.now());

                if (approval.getApprovalStatus()==0){
                    //不通过
                    workOrder1.setCityReviewStatus(1);
                    //设置不通过原因
                    workOrder1.setCityReviewComment(approval.getRejectionReason());
                    //设置不通过时间
                    workOrder1.setCityReviewTime(LocalDateTime.now());

                    workOrder1.setCityReviewerPhone(user.getPhone());
                }else if (approval.getApprovalStatus()==1){
                    //通过
                    workOrder1.setCityReviewStatus(2);
                    if (ObjectUtils.isNotEmpty(approval.getPunishmentFee())) {
                        workOrder1.setCostReductionAmount(approval.getPunishmentFee());
                    }else {
                        throw new RuntimeException("请填写压降金额");
                    }
                    workOrder1.setCityReviewerPhone(user.getPhone());
                    //设置通过时间
                    workOrder1.setCityReviewTime(LocalDateTime.now());
                    //设置总体通过
                    workOrder1.setOverallStatus(1);
                }
            }

        }
        workOrderMapper.updateById(workOrder1);
    }

    @Override
    public ApprovalHistory getApprovalHistory(Approval approval) {
        if (ObjectUtils.isNotEmpty(approval.getOrderNumber())) {
            //获取审批历史
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("id", approval.getOrderNumber());
            WorkOrder workOrder = workOrderMapper.selectOne(workOrderQueryWrapper);
            ApprovalHistory approvalHistory = new ApprovalHistory();

            if (ObjectUtils.isNotEmpty(workOrder)) {
                QueryWrapper<TSysUser> tSysUserQueryWrapper = new QueryWrapper<>();
                //  设置维护阶段
                tSysUserQueryWrapper.eq("phone", workOrder.getMaintainerPhone());
                TSysUser tSysUser = tSysUserMapper.selectOne(tSysUserQueryWrapper);
                 if (ObjectUtils.isNotEmpty(tSysUser)) {
                     //设置维护人名字
                    approvalHistory.setMaintainerName(tSysUser.getName());
                    //设置维护时间
                    approvalHistory.setMaintenanceTime(workOrder.getMaintainerTime());
                    //设置维护状态
                     if (workOrder.getMaintainerStatus() == 0) {
                         //未提交
                         approvalHistory.setStep(0);
                         approvalHistory.setMaintainerisPassed(2);
                     }else {
                         //已提交
                         approvalHistory.setMaintainerisPassed(1);
                     }

                 }
                 //设置县级审核阶段
                TSysUser tSysUser1=null;
                if (StringUtils.isNotEmpty(workOrder.getCountyReviewerPhone())){
                    QueryWrapper<TSysUser> tSysUserQueryWrapper1 = new QueryWrapper<>();
                    tSysUserQueryWrapper1.eq("phone", workOrder.getCountyReviewerPhone());
                    tSysUser1 = tSysUserMapper.selectOne(tSysUserQueryWrapper1);
                }
                if(workOrder.getCountyReviewStatus() == 0){
                    //未审核
                    approvalHistory.setCountyIsPassed(2);
                    if (workOrder.getMaintainerStatus() == 1) {
                        approvalHistory.setStep(1);
                    }
                }else if (workOrder.getCountyReviewStatus() == 1){
                    //未通过
                    approvalHistory.setCountyIsPassed(0);
                    if (ObjectUtils.isNotEmpty(tSysUser1)) {
                        //设置审批人名字
                        approvalHistory.setCountyReviewerName(tSysUser1.getName());
                    }
                    //设置不通过原因
                    approvalHistory.setCountyRefuseReason(workOrder.getCountyReviewComment());
                    //设置审批时间
                    approvalHistory.setCountyReviewTime(workOrder.getCountyReviewTime());
                }else if (workOrder.getCountyReviewStatus() == 2){
                    //已通过
                    approvalHistory.setCountyIsPassed(1);
                    if (ObjectUtils.isNotEmpty(tSysUser1)) {
                        //设置审批人名字
                        approvalHistory.setCountyReviewerName(tSysUser1.getName());
                    }
                    //设置审批时间
                    approvalHistory.setCountyReviewTime(workOrder.getCountyReviewTime());

                }
                //设置市级审核阶段
                TSysUser tSysUser2=null;
                if (StringUtils.isNotEmpty(workOrder.getCityReviewerPhone())){
                    QueryWrapper<TSysUser> tSysUserQueryWrapper2 = new QueryWrapper<>();
                    tSysUserQueryWrapper2.eq("phone", workOrder.getCityReviewerPhone());
                    tSysUser2 = tSysUserMapper.selectOne(tSysUserQueryWrapper2);
                }
                if (workOrder.getCityReviewStatus() == 0){
                    //未审核
                    approvalHistory.setCityIsPassed(2);
                    if (workOrder.getCountyReviewStatus() == 2) {
                        approvalHistory.setStep(2);
                    }
                }else if (workOrder.getCityReviewStatus() == 1){
                    //未通过
                    approvalHistory.setCityIsPassed(0);
                    //设置审批人名字
                    if (ObjectUtils.isNotEmpty(tSysUser2)) {
                        approvalHistory.setCityReviewerName(tSysUser2.getName());
                    }
                    //设置不通过原因
                    approvalHistory.setCityRefuseReason(workOrder.getCityReviewComment());
                    //设置审批时间
                    approvalHistory.setCityReviewTime(workOrder.getCityReviewTime());
                }else if (workOrder.getCityReviewStatus() == 2){
                    //已通过
                    approvalHistory.setCityIsPassed(1);
                    if (ObjectUtils.isNotEmpty(tSysUser2)) {
                        //设置审批人名字
                        approvalHistory.setCityReviewerName(tSysUser2.getName());
                    }
                    //设置审批时间
                    approvalHistory.setCityReviewTime(workOrder.getCityReviewTime());
                    //压降金额
                    approvalHistory.setCityTestAmount(workOrder.getCostReductionAmount());
                }
                //设置总体通过
                if (workOrder.getOverallStatus() == 0){
                    //未完结
                    approvalHistory.setIsFinished(0);
                }else if (workOrder.getOverallStatus() == 1){
                    //已完结
                    approvalHistory.setIsFinished(1);
                }

            }
            return approvalHistory;
        }else {
            throw new RuntimeException("请传递工单号");
        }
    }


    private List<ToDoVo> getcityList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        //获取市级全部数据列表
        QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
        List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
        if (CollectionUtils.isNotEmpty(workOrders)) {
            workOrders.forEach(workOrder -> {
                        ToDoVo toDoVo = new ToDoVo();
                        //设设置身份为市级管理员
                        toDoVo.setRole(5);
                        //根据工单流水号去查询异常数据
                        QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                        warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                        WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                        //设置工单流水号
                        toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                        //设置序号
                        toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                        //设置工单主题
                        toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                        //设置费用类型
                        toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                        //稽核工单涉及金额
                        toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                        //设置工单异常问题原因
                        toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                        //区县
                        toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                        //专业
                        toDoVo.setProfession(warningAndExceptionData.getProfession());
                        //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                        LocalDateTime updateTime = workOrder.getUpdateTime();
                        String pendingTime = updateTime.toString().substring(0, 10);
                        toDoVo.setPendingTime(pendingTime);
                        //添加回lis集合中
                        toDoVos.add(toDoVo);
                    }
            );
        }
        //市级选择的是代办或者已办直接返回空数组
        if (todoRequest.getType() == 2||todoRequest.getType() == 3){
            return new ArrayList<ToDoVo>();
        }
        return toDoVos;


    }

    private List<ToDoVo> getmaintenanceList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1)
        {
            //获取市级代维负责人的待办事项列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "代维");
            workOrderQueryWrapper.eq("county_review_status", 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            if (workOrder.getCityReviewStatus()==0){
                                toDoVo.setType(1);
                            }
                            else {
                                toDoVo.setType(2);
                            }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        else if
        (todoRequest.getType() == 2)
        {
            //获取自己代办没有办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "代维");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        } else if
        (todoRequest.getType() == 3)
        {
            //获取自己代办已办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "代维");
            workOrderQueryWrapper.in("city_review_status", 1,2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }

        }
        return toDoVos;

    }

    private List<ToDoVo> getpowerList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1)
        {
            //获取动力管理员的待办事项列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "动力");
            workOrderQueryWrapper.eq("county_review_status", 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            if (workOrder.getCityReviewStatus()==0){
                                toDoVo.setType(1);
                            }else {
                                toDoVo.setType(2);

                            }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
      else  if (todoRequest.getType() == 2)
        {
            //获取自己代办没有办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "动力");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        } else if
        (todoRequest.getType() == 3)
        {
            //获取自己代办已办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "动力");
            workOrderQueryWrapper.in("city_review_status", 1,2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }

        }
        return toDoVos;
    }


    private List<ToDoVo> getlineList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1)
        {
            //获取线路负责人的待办事项列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "线路");
            workOrderQueryWrapper.eq("county_review_status", 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                    if (workOrder.getCityReviewStatus() == 0) {
                            toDoVo.setType(1);
                    }else {
                        toDoVo.setType(2);
                    }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        else if
        (todoRequest.getType() == 2)
        {
            //获取自己代办没有办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "线路");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }

        }
        else if
        (todoRequest.getType() == 3)
        {
            //获取自己代办已办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "线路");
            workOrderQueryWrapper.in("city_review_status", 1,2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }


        return toDoVos;
    }


    private List<ToDoVo> getwirelessList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1)
        {
            //获取无线管理员的待办事项列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "无线");
            workOrderQueryWrapper.eq("county_review_status", 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            //设置状态
                            if (workOrder.getCityReviewStatus() == 0) {
                                toDoVo.setType(1);
                            } else  {
                                toDoVo.setType(2);
                            }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }else if
        (todoRequest.getType() == 2)
        {
            //获取自己代办没有办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "无线");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        else if
        (todoRequest.getType() == 3)
        {
            //获取自己代办已办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "无线");
            workOrderQueryWrapper.in("city_review_status", 1,2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }

        }

        return toDoVos;
    }


    private List<ToDoVo> getenterprisecustomerList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1)
        {
            //获取集客管理员的待办事项列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "集客");
            workOrderQueryWrapper.eq("county_review_status", 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            //设置状态
                            if (workOrder.getCityReviewStatus() == 0){
                                toDoVo.setType(1);
                            }else {
                                toDoVo.setType(2);
                            }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        else if
        (todoRequest.getType() == 2)
        {
            //获取自己代办没有办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "集客");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            //设置状态

                                toDoVo.setType(1);

                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        else if
        (todoRequest.getType() == 3)
        {
            //获取自己代办已办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "集客");
            workOrderQueryWrapper.in("city_review_status", 1,2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            //设置状态
                    toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        return toDoVos;
    }

    private List<ToDoVo> gethomecustomerList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1)
        {
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "家客");
            workOrderQueryWrapper.eq("county_review_status", 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            //设置状态
                            if (workOrder.getCityReviewStatus()==0){
                                toDoVo.setType(1);
                            }else {
                                toDoVo.setType(2);
                            }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        else if
        (todoRequest.getType() == 2)
        {
            //获取自己代办没有办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "家客");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders))
            {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }

        }
        else if
        (todoRequest.getType() == 3)
        {
            //获取自己代办已办的列表
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("profession", "家客");
            workOrderQueryWrapper.in("city_review_status", 1,2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
        return toDoVos;
    }

    private List<ToDoVo> getelectricityList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1)
        {
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("cost_category", "电费");
            workOrderQueryWrapper.eq("county_review_status", 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设置状态
                            if (workOrder.getCityReviewStatus()==0){
                                toDoVo.setType(1);
                            }else {
                                toDoVo.setType(2);
                            }
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        } else if (todoRequest.getType() == 2)
        {
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("cost_category", "电费");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders))
            {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }else if (todoRequest.getType() == 3)
        {
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("cost_category", "电费");
            workOrderQueryWrapper.in("city_review_status", 1,2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设设置身份为市级审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
            return toDoVos;

    }

    private ArrayList<ToDoVo> gettowList(ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType()==1)
        {
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("cost_category", "塔费");
            //县级审核已通过的列表
            workOrderQueryWrapper.eq("county_review_status", 2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设身份为市级塔费审核人
                            toDoVo.setRole(4);
                            //设置处理状态
                            if (workOrder.getCityReviewStatus() == 0) {
                                toDoVo.setType(1);
                            }else {
                                toDoVo.setType(2);
                            }
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        } else if (todoRequest.getType()==2)
        {
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("cost_category", "塔费");
            workOrderQueryWrapper.eq("city_review_status", 0);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设身份为市级塔费审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(1);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }

        }else if (todoRequest.getType()==3)
        {
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("cost_category", "塔费");
            workOrderQueryWrapper.in("city_review_status", 1, 2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设身份为市级塔费审核人
                            toDoVo.setRole(4);
                            toDoVo.setType(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(warningAndExceptionData.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            LocalDateTime updateTime = workOrder.getUpdateTime();
                            String pendingTime = updateTime.toString().substring(0, 10);
                            toDoVo.setPendingTime(pendingTime);
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }

        }
        return toDoVos;
    }

    private void getdistricList(Auditor auditor, ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1) {

            //获取到自己审核的区县
            String districtName = auditor.getDistrictName();
            //根据区县名称查询待办事项
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("district", districtName);
            //维护员已经处理的列表
            workOrderQueryWrapper.in("maintainer_status", 1, 2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //是否处理标识
                    if (workOrder.getCountyReviewStatus() == 0) {
                        toDoVo.setType(1);
                    }else {
                        toDoVo.setType(2);
                    }
                    //设置区县审核人身份
                            toDoVo.setRole(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(workOrder.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            if (ObjectUtils.isNotEmpty(workOrder.getUpdateTime())) {
                                LocalDateTime updateTime = workOrder.getUpdateTime();
                                String pendingTime = updateTime.toString().substring(0, 10);
                                toDoVo.setPendingTime(pendingTime);
                            }
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        } else if (todoRequest.getType() == 2)
        {

            //获取到自己待审核但是未审核的区县
            String districtName = auditor.getDistrictName();
            //根据区县名称查询待办事项
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("district", districtName);
            workOrderQueryWrapper.eq("county_review_status", 0);
            workOrderQueryWrapper.in("maintainer_status", 1, 2);

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设置为，未处理
                            toDoVo.setType(1);
                            //设置区县审核人身份
                            toDoVo.setRole(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(workOrder.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            if (ObjectUtils.isNotEmpty(workOrder.getUpdateTime())) {
                                LocalDateTime updateTime = workOrder.getUpdateTime();
                                String pendingTime = updateTime.toString().substring(0, 10);
                                toDoVo.setPendingTime(pendingTime);
                            }
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );


            }
        } else if (todoRequest.getType() == 3)
        {
            //查看自己已经处理的列表
            //获取到自己待审核的区县
            String districtName = auditor.getDistrictName();
            //根据区县名称查询待办事项
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("district", districtName);
            workOrderQueryWrapper.in("county_review_status", 1, 2);
            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //设置区县审核人身份
                            toDoVo.setType(2);
                            toDoVo.setRole(2);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(workOrder.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            if (ObjectUtils.isNotEmpty(workOrder.getUpdateTime())) {
                                LocalDateTime updateTime = workOrder.getUpdateTime();
                                String pendingTime = updateTime.toString().substring(0, 10);
                                toDoVo.setPendingTime(pendingTime);
                            }
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );

            }
        }
    }
    private void getdistricListadmin(Auditor auditor, ArrayList<ToDoVo> toDoVos, TodoRequest todoRequest) {
        if (todoRequest.getType() == 1) {

            //获取到自己审核的区县
            String districtName = auditor.getDistrictName();
            //根据区县名称查询待办事项
            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
            workOrderQueryWrapper.eq("district", districtName);
            //维护员已经处理的列表

            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
            if (CollectionUtils.isNotEmpty(workOrders)) {
                workOrders.forEach(workOrder -> {
                            ToDoVo toDoVo = new ToDoVo();
                            //是否处理标识
                            if (workOrder.getCountyReviewStatus() == 0) {
                                toDoVo.setType(1);
                            }else {
                                toDoVo.setType(2);
                            }
                            //设置区县审核人身份
                            toDoVo.setRole(3);
                            //根据工单流水号去查询异常数据
                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
                            //设置工单流水号
                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
                            //设置序号
                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
                            //设置工单主题
                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
                            //设置费用类型
                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
                            //稽核工单涉及金额
                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
                            //设置工单异常问题原因
                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
                            //区县
                            toDoVo.setDistrict(workOrder.getDistrict());
                            //专业
                            toDoVo.setProfession(warningAndExceptionData.getProfession());
                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
                            if (ObjectUtils.isNotEmpty(workOrder.getUpdateTime())) {
                                LocalDateTime updateTime = workOrder.getUpdateTime();
                                String pendingTime = updateTime.toString().substring(0, 10);
                                toDoVo.setPendingTime(pendingTime);
                            }
                            //添加回lis集合中
                            toDoVos.add(toDoVo);
                        }
                );
            }
        }
//        else if (todoRequest.getType() == 2) {
//
//            //获取到自己待审核但是未审核的区县
//            String districtName = auditor.getDistrictName();
//            //根据区县名称查询待办事项
//            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
//            workOrderQueryWrapper.eq("district", districtName);
//            workOrderQueryWrapper.eq("county_review_status", 0);
//            workOrderQueryWrapper.in("maintainer_status", 1, 2);
//
//            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
//            if (CollectionUtils.isNotEmpty(workOrders)) {
//                workOrders.forEach(workOrder -> {
//                            ToDoVo toDoVo = new ToDoVo();
//                            //设置为，未处理
//                            toDoVo.setType(1);
//                            //设置区县审核人身份
//                            toDoVo.setRole(2);
//                            //根据工单流水号去查询异常数据
//                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
//                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
//                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
//                            //设置工单流水号
//                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
//                            //设置序号
//                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
//                            //设置工单主题
//                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
//                            //设置费用类型
//                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
//                            //稽核工单涉及金额
//                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
//                            //设置工单异常问题原因
//                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
//                            //区县
//                            toDoVo.setDistrict(workOrder.getDistrict());
//                            //专业
//                            toDoVo.setProfession(warningAndExceptionData.getProfession());
//                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
//                            if (ObjectUtils.isNotEmpty(workOrder.getUpdateTime())) {
//                                LocalDateTime updateTime = workOrder.getUpdateTime();
//                                String pendingTime = updateTime.toString().substring(0, 10);
//                                toDoVo.setPendingTime(pendingTime);
//                            }
//                            //添加回lis集合中
//                            toDoVos.add(toDoVo);
//                        }
//                );
//
//
//            }
//        }
//        else if (todoRequest.getType() == 3)
//        {
//
//            //查看自己已经处理的列表
//            //获取到自己待审核的区县
//            String districtName = auditor.getDistrictName();
//            //根据区县名称查询待办事项
//            QueryWrapper<WorkOrder> workOrderQueryWrapper = new QueryWrapper<>();
//            workOrderQueryWrapper.eq("district", districtName);
//            workOrderQueryWrapper.in("county_review_status", 1, 2);
//            List<WorkOrder> workOrders = workOrderMapper.selectList(workOrderQueryWrapper);
//            if (CollectionUtils.isNotEmpty(workOrders)) {
//                workOrders.forEach(workOrder -> {
//                            ToDoVo toDoVo = new ToDoVo();
//                            //设置区县审核人身份
//                            toDoVo.setType(2);
//                            toDoVo.setRole(2);
//                            //根据工单流水号去查询异常数据
//                            QueryWrapper<WarningAndExceptionData> warningAndExceptionDataQueryWrapper = new QueryWrapper<>();
//                            warningAndExceptionDataQueryWrapper.eq("id", workOrder.getWarExcpId());
//                            WarningAndExceptionData warningAndExceptionData = warningAndExceptionDataMapper.selectOne(warningAndExceptionDataQueryWrapper);
//                            //设置工单流水号
//                            toDoVo.setWorkOrderNumber(workOrder.getWorkOrderNumber());
//                            //设置序号
//                            toDoVo.setOrderNumber(String.valueOf(workOrder.getId()));
//                            //设置工单主题
//                            toDoVo.setWorkOrderSubject(warningAndExceptionData.getWorkOrderSubject());
//                            //设置费用类型
//                            toDoVo.setExpenseType(warningAndExceptionData.getCostCategory());
//                            //稽核工单涉及金额
//                            toDoVo.setAuditedOrderAmount(warningAndExceptionData.getAuditAmount());
//                            //设置工单异常问题原因
//                            toDoVo.setAbnormalReason(warningAndExceptionData.getExceptionReason());
//                            //区县
//                            toDoVo.setDistrict(workOrder.getDistrict());
//                            //专业
//                            toDoVo.setProfession(warningAndExceptionData.getProfession());
//                            //设置代办时间，需要把时间转换成yyyy-mm-dd格式
//                            if (ObjectUtils.isNotEmpty(workOrder.getUpdateTime())) {
//                                LocalDateTime updateTime = workOrder.getUpdateTime();
//                                String pendingTime = updateTime.toString().substring(0, 10);
//                                toDoVo.setPendingTime(pendingTime);
//                            }
//                            //添加回lis集合中
//                            toDoVos.add(toDoVo);
//                        }
//                );
//
//            }
//        }
    }

}